
// 修改为可挂可摘的方法

import {onMounted, onUnmounted,reactive} from "vue";
export default ()=>{
    let point = reactive({
      x: 0,
      y: 0
    })
    function changeXY(event) {
        console.log(`点击坐标：x:${event.pageX} y:${event.pageY}`)
        point.x = event.pageX
        point.y = event.pageY
    }

// 挂上
    onMounted(() => {
        window.addEventListener('mouseover', changeXY)
    })
//摘下
    onUnmounted(() => {
        window.removeEventListener('mouseover', changeXY)
    })
    return point
}